import java.util.*;

public class Text {
    //131
    List<List<String>> ret = new ArrayList<>();
    List<String> tmp = new LinkedList<>();
    private boolean check(String s,int startindex,int i) {
        while(startindex < i) {
            if(s.charAt(startindex)==(s.charAt(i))) {
                startindex++;
                i--;
            }else {
                return false;
            }
        }
        return true;
    }
    public void func (String str, int startindex) {
        if(startindex >= str.length()) {
            ret.add(new ArrayList<>(tmp));
            return;
        }

        for(int i = startindex; i < str.length(); i++) {
            if(check(str,startindex,i)) {
                String s = str.substring(startindex,i+1);
                tmp.add(s);
            }else{
                continue;
            }
            func(str,i+1);
            tmp.remove(tmp.size()-1);
        }
    }
    public List<List<String>> partition(String s) {
        func(s,0);
        return ret;
    }
}
